package com.base.myproject.client.HR.Self;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.base.myproject.client.busi.BaseStore;
import com.base.myproject.client.busi.LasyObejct;
import com.base.myproject.client.busi.BO.BusiObject;
import com.base.myproject.client.jdbc.StoreInfo;
import com.base.myproject.client.ui.BaseGridPanel;
import com.base.myproject.client.ui.celleditor.BaseComboBoxX;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.Element;

public class SelfBcode_Cer extends LayoutContainer implements LasyObejct {
	
	BaseStore<BusiObject> mainstore = null;

	public SelfBcode_Cer(BaseStore<BusiObject> mainstore){
		this.mainstore = mainstore;
		init();
	}
	
	public void init(){
		initWidget();
	}
	
	 protected void onRender(Element parent, int pos) {  
		 super.onRender(parent, pos);  
	     VerticalPanel vp = new VerticalPanel();  
	     vp.setSpacing(5);  

	     TabPanel panel = new TabPanel();  
	     //panel.setPlain(true);  //设置使用panel背景
	     panel.setSize(760, 374);  
	     
	     TabItem jycd = new TabItem("教育程度");  
	     jycd.add(createbcode_educationGrid());
	     panel.add(jycd);  
	     
	     TabItem zige = new TabItem("资格");  
	     zige.add(create_bcode_quality_Grid());  
	     panel.add(zige);  
	     
	     TabItem ji_neng = new TabItem("技能");  
	     ji_neng.add(create_bcode_skill_Grid());
	     panel.add(ji_neng);  
	   
	     
	     
	     
	     TabItem z_j = new TabItem("证件");  
	     z_j.add(create_bcode_cer_Grid());  
	     panel.add(z_j);  
	     
	     vp.add(panel);  
	      add(vp);  
	}
	 
	BaseStore<BusiObject> bcode_education_store = null;

	public	BaseStore<BusiObject> getbcode_educationStore() {
		if (bcode_education_store == null) {
				createbcode_educationStore();
		}
		return bcode_education_store;
	}

	public 	BaseStore<BusiObject> createbcode_educationStore() {
		ModelType type = new ModelType();
		type.setRoot("records");
		type.setRecordName("record");
		type.setTotalName("totle");
		type.addField("icode");
		type.getField("icode").setType(Long.class);
		type.addField("bcode");
		type.getField("bcode").setType(String.class);
		type.addField("no_");
		type.getField("no_").setType(String.class);
		type.addField("Major");
		type.getField("Major").setType(String.class);
		type.addField("education");
		type.getField("education").setType(String.class);
		type.addField("cer");
		type.getField("cer").setType(String.class);
		type.addField("Organization");
		type.getField("Organization").setType(String.class);
		type.addField("Country");
		type.getField("Country").setType(String.class);
		type.addField("startdate");
		type.getField("startdate").setType(Date.class);
		type.addField("enddate");
		type.getField("enddate").setType(Date.class);
		type.addField("city");
		type.getField("city").setType(String.class);
		type.addField("getdate");
		type.getField("getdate").setType(Date.class);  //数据库要修改这个字段
		type.addField("mark");
		type.getField("mark").setType(String.class);
		StoreInfo info = new StoreInfo();
		info.setTablename("bcode_education");
		info.setKeyname(new String[] { "icode" });
		info.setSql("select * from bcode_education where bcode ='{bcode}'");
		info.setParent(mainstore);// 关联主表
	    info.setLinkparentcolumns(new String[] { "bcode" }); // 关联主表字段
		info.setLinkparent_chile_columns(new String[] { "bcode" });//
			// 关联主表字段
		bcode_education_store = new BaseStore<BusiObject>(type, info);
		return bcode_education_store;
	}

	BaseGridPanel bcode_educationgrid = null;

	public 	BaseGridPanel createbcode_educationGrid() {
		List<ColumnConfig> columns = new ArrayList<ColumnConfig>();

		ColumnConfig C4 = new ColumnConfig("Major", "主修", 60);
		columns.add(C4);
		ColumnConfig C5 = new ColumnConfig("education", "教育程度", 60);
		BaseComboBoxX bc5 = new BaseComboBoxX("name","dictionary", "where type='hr_education'");
		columns.add(C5);
		ColumnConfig C6 = new ColumnConfig("cer", "证书", 60);
		columns.add(C6);
		ColumnConfig C7 = new ColumnConfig("Organization", "机构", 80);
		columns.add(C7);
		ColumnConfig C8 = new ColumnConfig("Country", "国家", 60);
		BaseComboBoxX bc8 = new BaseComboBoxX("name","dictionary", "where type='hr_Country'");
		columns.add(C8);
		ColumnConfig C9 = new ColumnConfig("startdate", "开始日期", 80);
		//DateField dateField9 = new DateField();  
	    //dateField9.getPropertyEditor().setFormat(DateTimeFormat.getFormat("yyyy-dd-MM"));  
		C9.setDateTimeFormat(DateTimeFormat.getFormat("yyyy-dd-MM"));
		columns.add(C9);
		ColumnConfig C10 = new ColumnConfig("enddate", "结束日期", 80);
		DateField dateField10 = new DateField();  
		dateField10.getPropertyEditor().setFormat(DateTimeFormat.getFormat("yyyy-dd-MM"));  
		C10.setDateTimeFormat(DateTimeFormat.getFormat("yyyy-dd-MM"));
		columns.add(C10);
		ColumnConfig C11 = new ColumnConfig("city", "城市", 60);
		columns.add(C11);
		ColumnConfig C12 = new ColumnConfig("getdate", "获得日期", 80);
		DateField dateField12 = new DateField();  
		dateField12.getPropertyEditor().setFormat(DateTimeFormat.getFormat("yyyy-dd-MM"));  
		C12.setDateTimeFormat(DateTimeFormat.getFormat("yyyy-dd-MM"));
	    columns.add(C12);
		ColumnConfig C13 = new ColumnConfig("mark", "备注", 140);
		columns.add(C13);

		ColumnModel cm = new ColumnModel(columns);
		bcode_educationgrid = new BaseGridPanel(getbcode_educationStore(), cm);
		bcode_educationgrid.getBg().setHeight(250);
		//bcode_educationgrid.getBg().setWidth(760);
		bcode_educationgrid.getBg().setBorders(false);
		return bcode_educationgrid;
	}
		
	BaseStore<BusiObject> bcode_quality_store = null;

	public 	BaseStore<BusiObject> get_bcode_quality_Store() {
		if (bcode_quality_store == null) {
			create_bcode_quality_Store();
		}
		return bcode_quality_store;
	}

	public BaseStore<BusiObject> create_bcode_quality_Store() {
		ModelType type = new ModelType();
		type.setRoot("records");
		type.setRecordName("record");
		type.setTotalName("totle");
		type.addField("icode");
		type.getField("icode").setType(Long.class);
		type.addField("bcode");
		type.getField("bcode").setType(String.class);
		type.addField("Qualifications");
		type.getField("Qualifications").setType(String.class);
		type.addField("Organization");
		type.getField("Organization").setType(String.class);
		type.addField("menber");
		type.getField("menber").setType(String.class);
		type.addField("description");
		type.getField("description").setType(String.class);
		type.addField("no_");
		type.getField("no_").setType(String.class);
		StoreInfo info = new StoreInfo();
		info.setTablename("bcode_quality");
		info.setKeyname(new String[] { "icode" });
		info.setSql("select * from bcode_quality where bcode ='{bcode}'");
		info.setParent(mainstore);// 关联主表
		info.setLinkparentcolumns(new String[] { "bcode" }); // 关联主表字段
		info.setLinkparent_chile_columns(new String[] { "bcode" });//
			// 关联主表字段
		bcode_quality_store = new BaseStore<BusiObject>(type, info);
		return bcode_quality_store;
	}

	BaseGridPanel bcode_quality_grid = null;

	BaseGridPanel create_bcode_quality_Grid() {
		List<ColumnConfig> columns = new ArrayList<ColumnConfig>();

//		ColumnConfig C1 = new ColumnConfig("icode", "icode", 80);
//		columns.add(C1);
//		ColumnConfig C2 = new ColumnConfig("bcode", "bcode", 80);
//		columns.add(C2);
		ColumnConfig C3 = new ColumnConfig("Qualifications", "资格",
				80);
		columns.add(C3);
		ColumnConfig C4 = new ColumnConfig("Organization", "组织", 80);
		columns.add(C4);
		ColumnConfig C5 = new ColumnConfig("menber", "会员", 80);
		columns.add(C5);
		ColumnConfig C6 = new ColumnConfig("description", "描述", 150);
		columns.add(C6);

		ColumnModel cm = new ColumnModel(columns);
		bcode_quality_grid = new BaseGridPanel(get_bcode_quality_Store(), cm);
		bcode_quality_grid.getBg().setHeight(250);
		bcode_quality_grid.getBg().setBorders(false);
		//bcode_quality_grid.getBg().setWidth(730);
		return bcode_quality_grid;
	}

	BaseStore<BusiObject> bcode_skill_store = null;

	BaseStore<BusiObject> get_bcode_skill_Store() {
		if (bcode_skill_store == null) {
			create_bcode_skill_Store();
		}
		return bcode_skill_store;
	}

	BaseStore<BusiObject> create_bcode_skill_Store() {
		ModelType type = new ModelType();
		type.setRoot("records");
		type.setRecordName("record");
		type.setTotalName("totle");
		type.addField("icode");
		type.getField("icode").setType(Long.class);
		type.addField("bcode");
		type.getField("bcode").setType(String.class);
		type.addField("Skill");
		type.getField("Skill").setType(String.class);
		type.addField("mark");
		type.getField("mark").setType(String.class);
		type.addField("no_");
		type.getField("no_").setType(String.class);
		StoreInfo info = new StoreInfo();
		info.setTablename("bcode_skill");
		info.setKeyname(new String[] { "icode" });
		info.setSql("select * from bcode_skill where bcode ='{bcode}'");
		info.setParent(mainstore);// 关联主表
		info.setLinkparentcolumns(new String[] { "bcode" }); // 关联主表字段
		info.setLinkparent_chile_columns(new String[] { "bcode" });//
		// 关联主表字段
		bcode_skill_store = new BaseStore<BusiObject>(type, info);
		return bcode_skill_store;
	}

	BaseGridPanel bcode_skill_grid = null;

	BaseGridPanel create_bcode_skill_Grid() {
		List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
		ColumnConfig C3 = new ColumnConfig("Skill", "技能", 80);
		columns.add(C3);
		ColumnConfig C4 = new ColumnConfig("mark", "备注", 80);
		columns.add(C4);


		ColumnModel cm = new ColumnModel(columns);
		bcode_skill_grid = new BaseGridPanel(get_bcode_skill_Store(), cm);
		bcode_skill_grid.getBg().setHeight(250);
		bcode_skill_grid.getBg().setBorders(false);
		
		return bcode_skill_grid;
	}

	BaseStore<BusiObject> bcode_cer_store = null;

	BaseStore<BusiObject> get_bcode_cer_Store() {
		if (bcode_cer_store == null) {
			create_bcode_cer_Store();
		}
		return bcode_cer_store;
	}

	BaseStore<BusiObject> create_bcode_cer_Store() {
		ModelType type = new ModelType();
		type.setRoot("records");
		type.setRecordName("record");
		type.setTotalName("totle");
		type.addField("icode");
		type.getField("icode").setType(Long.class);
		type.addField("bcode");
		type.getField("bcode").setType(String.class);
		type.addField("no_");
		type.getField("no_").setType(String.class);
		type.addField("cerSpecies");
		type.getField("cerSpecies").setType(String.class);
		type.addField("certype");
		type.getField("certype").setType(String.class);
		type.addField("cerno");
		type.getField("cerno").setType(String.class);
		type.addField("DMSno");
		type.getField("DMSno").setType(String.class);
		type.addField("mark");
		type.getField("mark").setType(String.class);
		StoreInfo info = new StoreInfo();
		info.setTablename("bcode_cer");
		info.setKeyname(new String[] { "icode" });
		info.setSql("select * from bcode_cer where bcode ='{bcode}'");
		info.setParent(mainstore);// 关联主表
		info.setLinkparentcolumns(new String[] { "bcode" }); // 关联主表字段
		info.setLinkparent_chile_columns(new String[] { "bcode" });//
		// 关联主表字段
		bcode_cer_store = new BaseStore<BusiObject>(type, info);
		return bcode_cer_store;
	}

	BaseGridPanel bcode_cer_grid = null;

	BaseGridPanel create_bcode_cer_Grid() {
		List<ColumnConfig> columns = new ArrayList<ColumnConfig>();

		ColumnConfig C4 = new ColumnConfig("cerSpecies", "证书种类", 80);
		columns.add(C4);
		ColumnConfig C5 = new ColumnConfig("certype", "证书类型", 80);
		columns.add(C5);
		ColumnConfig C6 = new ColumnConfig("cerno", "证书编码", 80);
		columns.add(C6);
		ColumnConfig C7 = new ColumnConfig("DMSno", "DMS编码", 80);
		columns.add(C7);
		ColumnConfig C8 = new ColumnConfig("mark", "备注", 80);
		columns.add(C8);

		ColumnModel cm = new ColumnModel(columns);
		bcode_cer_grid = new BaseGridPanel(get_bcode_cer_Store(), cm);
		bcode_cer_grid.getBg().setHeight(250);
		bcode_cer_grid.getBg().setBorders(false);
		return bcode_cer_grid;
	}
	public void initWidget(){
		
	}
	
	@Override
	public boolean isopen() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean open() {
		// TODO Auto-generated method stub
		return false;
	}

}
